/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package luft27.comm.dozor;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

/**
 *
 * @author amalikov
 */
public class Info implements MessagePayload {
	public byte protocol;
	public String version;
	
	@Override
	public byte[] get() {
		ByteBuffer bb = ByteBuffer.allocate(256).order(ByteOrder.LITTLE_ENDIAN);
		bb.put(protocol);
		bb.put(version.getBytes());
		return Arrays.copyOf(bb.array(), bb.position());
	}

	@Override
	public void set(byte[] data) {
		ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
		protocol = bb.get();
		version = new String(data, 1, data.length - 1);
	}
	
}
